﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

namespace UI
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //TBLogins logins = new TBLogins()
                //{
                //    Password = "'open'",
                //    UserName = "'AI_101'"
                //};
                //userAccess.userLogin(logins);
            }
        }

        protected void btn_Register_Click(object sender, EventArgs e)
        {
            if (IsValid)//所有非空验证通过
            {
                //实体类赋值
                TBLogins logins = new TBLogins()
                {
                    UserName = txt_username.Text.Trim(),
                    Password = txt_password.Text.Trim(),
                    MobileNumber = txt_phone.Text.Trim()
                };

                //调用注册方法
                int count = BLL.userAccess.userRegister(logins);

                int a = 1;
                if (count > 0)//注册成功
                {
                    Response.Write("<script>alert('注册成功！')</script>");
                }
                else
                {
                    Response.Write("<script>alert('注册失败！')</script>");
                }
            }
            else
            {

            }
        }
    }
}